package com.example.demo.controller;


import com.example.demo.pojo.User;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;
import java.util.List;

import static com.fasterxml.jackson.databind.type.LogicalType.Array;


@RestController
public class PrimitiveController {

    @RequestMapping("/primitive")

//    public String primitive(HttpServletRequest req){
//        String name=req.getParameter("name");
//        String age=req.getParameter("age");
//        int ageInt=Integer.parseInt(age);
//
//        System.out.println(name+""+ageInt);
//        return "OK";
//    }

//    springboot方式
    public String primitive(String name,Integer age){

        System.out.println(name+"："+age);
        return "OK";
    }

    @RequestMapping("pojo")
    public String pojo(User user){
        System.out.println(user);
        return "OK2";
    }

    @RequestMapping("complexpojo")
    public String complexpojo(User user){
        System.out.println(user);
        return "OK3";
    }

//    数组
    @RequestMapping("array")
    public String array(String[] hobby){
        System.out.println(Arrays.toString(hobby));
        return "OK4";
    }

//    集合
    @RequestMapping("list")
    public String list(@RequestParam List<String> hobby){
        System.out.println(hobby);
        return "OK5";
    }


}
